package com.irssproject.app.web.action.JSONWrappers;

import com.irssproject.app.entitats.Item;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ItemJSON implements Serializable {

	private static final long serialVersionUID = 5340473290545761101L;

	private Long id;
	
	private String title;
	private String link;
	private Date publishedDate;
	private String dataPublicacioDisplay;
	private String content;
	
	public ItemJSON(){}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String titol) {
		this.title = titol;
	}

	public String getLink() {
		return link;
	}

	public void setLink(String link) {
		this.link = link;
	}

	public Date getPublishedDate() {
		return publishedDate;
	}

	public void setPublishedDate(Date dataPublicacio) {
		this.publishedDate = dataPublicacio;
	}

	public void setContent(String contingut) {
		this.content = contingut;
	}

	public String getContent() {
		return content;
	}

	public void setDataPublicacioDisplay(String dataPublicacioDisplay) {
		this.dataPublicacioDisplay = dataPublicacioDisplay;
	}

	public String getDataPublicacioDisplay() {
		return dataPublicacioDisplay;
	}
        
        public static List<ItemJSON> toJSONList(List<Item> listItems) {
            
            List<ItemJSON> liIJSON = new ArrayList<ItemJSON>();
            ItemJSON iJSON = new ItemJSON();
            for (Item item : listItems){
                iJSON = new ItemJSON();
                iJSON.setDataPublicacioDisplay(item.getDataPublicacioString());
                iJSON.setPublishedDate(item.getPublishedDate());
                iJSON.setContent(item.getContent());
                iJSON.setId(item.getId());
                iJSON.setLink(item.getLink());
                iJSON.setTitle(item.getTitle()); 
                liIJSON.add(iJSON);
            }
            return liIJSON;
        }

}
